home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best of www.BestZips.com (Collector's Edition)
/
Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO
/
tutorial
/
adatu311.zip
/
TXT2DAT.ADA
< prev
next >
Wrap
Text File
|
1996-01-10
|
3KB
|
57 lines
-- TXT2DAT.ADA Ver. 3.11 10-JAN-1996 Copyright 1988-1996 John J. Herro
--
-- SOFTWARE INNOVATIONS TECHNOLOGY http://members.aol.com/AdaTutor
-- 1083 MANDARIN DR NE ftp://members.aol.com/AdaTutor
-- PALM BAY FL 32905-4706
-- johnherro@aol.com
-- (407) 951-0233 john.herro%374-38-2@satlink.oau.org
--
-- After running DAT2TXT on a PC and transferring the resulting TUTOR.TXT
-- file to another computer, compile and run this program on the other
-- computer to create ADA_TUTR.DAT on that machine.
--
with Direct_IO, Text_IO;
procedure TXT2DAT is
subtype Block_Subtype is String(1 .. 64);
package Random_IO is new Direct_IO(Block_Subtype);
Text_File : Text_IO.File_Type; -- The input file.
Data_File : Random_IO.File_Type; -- The output file.
OK : Boolean := True; -- True when both files open successfully.
Input : String(1 .. 65); -- Line of text read from TUTOR.TXT.
Len : Integer; -- Length of line read from TUTOR.TXT.
Legal_Note : constant String := " Copyright 1988-96 John J. Herro ";
-- Legal_Note isn't used by the program, but it causes
-- most compilers to place this string in the .EXE file.
begin
begin
Text_IO.Open(Text_File, Mode => Text_IO.In_File, Name => "TUTOR.TXT");
exception
when Text_IO.Name_Error =>
Text_IO.Put_Line(
"I'm sorry. The file TUTOR.TXT seems to be missing.");
OK := False;
end;
begin
Random_IO.Create(Data_File, Random_IO.Out_File, Name => "ADA_TUTR.DAT");
exception
when others =>
Text_IO.Put_Line("I'm sorry. I can't seem to create ADA_TUTR.DAT.");
Text_IO.Put_Line("Perhaps that file already exists?");
OK := False;
end;
if OK then
while not Text_IO.End_Of_File(Text_File) loop
Text_IO.Get_Line(File => Text_File, Item => Input, Last => Len);
if Len > 3 then -- In case extra CRs/LFs were added to the text file.
Input(Len + 1 .. 64) := (others => ' ');
-- In case trailing blanks were lost when transferring TUTOR.TXT.
Random_IO.Write(Data_File, Item => Input(1 .. 64));
end if;
end loop;
Text_IO.Close(Text_File);
Random_IO.Close(Data_File);
Text_IO.Put_Line("ADA_TUTR.DAT created.");
end if;
end TXT2DAT;